﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Windows.Interop; 
using Rabbit.Modal;
using System.Diagnostics;
using System.ComponentModel; 

namespace testProject
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Window1_Loaded);
            DataContext = this;
        }
        public string CaputerScreenHotKey
        {
            get { return (string)GetValue(CaputerScreenHotKeyProperty); }
            set { SetValue(CaputerScreenHotKeyProperty, value); }
        }

        // Using a DependencyProperty as the backing store for CaputerScreenHotKey.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CaputerScreenHotKeyProperty =
            DependencyProperty.Register("CaputerScreenHotKey",
            typeof(string),
            typeof(Window1),
            new UIPropertyMetadata(""));


        public string GetLetterHotKey
        {
            get { return (string)GetValue(GetLetterHotKeyProperty); }
            set { SetValue(GetLetterHotKeyProperty, value); }
        }

        // Using a DependencyProperty as the backing store for GetLetterHotKey.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty GetLetterHotKeyProperty =
            DependencyProperty.Register("GetLetterHotKey", typeof(string), typeof(Window1), new UIPropertyMetadata(""));

        public string GetCommentHotKey
        {
            get { return (string)GetValue(GetCommentHotKeyProperty); }
            set { SetValue(GetCommentHotKeyProperty, value); }
        }

        // Using a DependencyProperty as the backing store for GetCommentHotKey.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty GetCommentHotKeyProperty =
            DependencyProperty.Register("GetCommentHotKey", typeof(string), typeof(Window1), new UIPropertyMetadata(""));
         
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                DPClass dp1 = new DPClass();
                DPClass dp2 = new DPClass();

                dp1.MainWindowBackgroundOpacity = 3;
                dp2.MainWindowBackgroundOpacity = 5;

                //Rabbit.Utils.HotKeyHelper hk = new Rabbit.Utils.HotKeyHelper(this, ModifierKeys.Control, System.Windows.Forms.Keys.C);
                //hk.OnHotKeyClicked = () =>
                //{
                //    System.Windows.MessageBox.Show("Hello from B");
                //};

                //Rabbit.Utils.HotKeyHelper hk2 = new Rabbit.Utils.HotKeyHelper(this, ModifierKeys.Control | ModifierKeys.Alt, System.Windows.Forms.Keys.B);
                //hk2.OnHotKeyClicked = () =>
                //{
                //    System.Windows.MessageBox.Show("Hello from Ctr+Alt+A");
                //};
            }
            catch (RegisterHotKeyFailedException ex)
            {
                System.Windows.MessageBox.Show("registered error");
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message); 
            }
        }

        void hkB_OnHotKey()
        {
            System.Windows.MessageBox.Show("b is fired");
        }

        void hk_OnHotKey()
        {
            System.Windows.MessageBox.Show("fired");
        }
         
        private void btnCtrD_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.MessageBox.Show("Control+D is pressed!");
        }

        private void btnCtrlF_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.MessageBox.Show("Control+F is pressed!");
        }


        private void btnGetHotKeys_Click(object sender, RoutedEventArgs e)
        {
            string a;
        }

        private void HotKeyGeneratorTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            Rabbit.Utils.Common.GetListBoxItemFromChild(sender as DependencyObject).IsSelected = true;

        }
    }

    public class DPClass : INotifyPropertyChanged
{
    private double? _MainWindowBackgroundOpacity;
    public double? MainWindowBackgroundOpacity
    {
        get
        {
            return _MainWindowBackgroundOpacity;
        }
        set
        {
            if (value != _MainWindowBackgroundOpacity)
            {
                _MainWindowBackgroundOpacity = value;
                NotifyPropertyChanged("MainWindowBackgroundOpacity");
            }
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
}
